﻿// Copyright: 2012 
// Author: Minh Vu - YoungJ
// File name: Class1.cs
// Solution: WpfEncryption
// Project: WpfEncryption
// Time: 9:21 AM 28/05/2012
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace WpfEncryption.Converter
{
    public class MD4Converter : IMultiValueConverter
    {
        #region Implementation of IValueConverter

        public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
        {
            var text = value[0].ToString();
            var upcase = System.Convert.ToBoolean(value[1]);
            var isfile = System.Convert.ToBoolean(value[2]);
            var visible = System.Convert.ToBoolean(value[3]);
            if (!visible) return string.Empty;
            var encrypt = isfile ? "Only text, not support file" : text.EncryptMD4();
            return upcase ? encrypt.ToUpper() : encrypt;
        }

        public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
        {
            var result = new[]
                             {
                                 DependencyProperty.UnsetValue, DependencyProperty.UnsetValue,
                                 DependencyProperty.UnsetValue, DependencyProperty.UnsetValue
                             };
            return result;
        }

        #endregion
    }
}